package com.zjj.day0425.regex;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date 2025/4/25
 */
import java.util.Scanner;
import java.util.regex.Pattern;

public class PasswordStrengthChecker {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要校验的密码：");
        String password = scanner.nextLine();
        scanner.close();

        String strength = checkPasswordStrength(password);
        System.out.println("该密码的强度为：" + strength);
    }

    public static String checkPasswordStrength(String password) {
        boolean hasDigit = Pattern.compile("\\d").matcher(password).find();
        boolean hasLetter = Pattern.compile("[a-zA-Z]").matcher(password).find();
        boolean hasSpecial = Pattern.compile("[^a-zA-Z0-9]").matcher(password).find();

        if (hasDigit && hasLetter && hasSpecial) {
            return "强";
        } else if ((hasDigit && hasLetter) || (hasDigit && hasSpecial) || (hasLetter && hasSpecial)) {
            return "中";
        } else {
            return "弱";
        }
    }
}